home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Games of Daze
/
Infomagic - Games of Daze (Summer 1995) (Disc 2 of 2).iso
/
cheats
/
dsge
/
dsge.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-12
|
32KB
|
1,315 lines
#include <mem.h>
#include <conio.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define mmx1 4 /* Main menu X1 coordinate */
#define mmy1 2 /* Main menu Y1 coordinate */
#define mmx2 42 /* Main menu X2 coordinate */
#define mmy2 24 /* Main menu Y2 coordinate */
#define imx1 45 /* Info menu X1 coordinate */
#define imy1 3 /* Info menu Y1 coordinate */
#define imx2 77 /* Info menu X2 coordinate */
#define imy2 10 /* Info menu Y2 coordinate */
#define omx1 45 /* Other menu X1 coordinate */
#define omy1 12 /* Other menu Y1 coordinate */
#define omx2 77 /* Other menu X2 coordinate */
#define omy2 16 /* Other menu Y2 coordinate */
#define HeaderLen 7 /* Length of header string */
#define MaxMenuItems 19 /* Maximum items on the main menu */
#define MaxOMenuItems 1 /* Maximum items on the other menu */
#define PlayerHeader "RLPD\x04\x00\x10\x00" /* Header for player file */
FILE *File;
unsigned int VideoSeg; /* Video Segment */
struct text_info ti; /* Screen info */
char ScrnBuff[0xFA0]; /* Screen size (80x25) */
char SaveGame[25]; /* Name of current save game */
char MiscMenuBuff[0xFA0]; /* Miscelaneous screen buffer */
char *MMenuItem[MaxMenuItems]; /* Items on the main menu */
char *OMenuItem[MaxOMenuItems]; /* Items on the other menu */
char MainMenuBuff[0xFA0]; /* Menu screen */
char FileBuff[2212]; /* File buffer */
char *FileName; /* Take a guess */
char MiscMenuItem[16][26]; /* Miscelaneous items on menus */
char *TempStr; /* Miscelaneous string variable */
char PlayerName[7]; /* Name of player */
char input; /* Main input variable */
int BaseInfo, error, I, bytes, OMItem = 0, MMItem = 0; /* Color Definitions */
int FgColor = 0; /* Edit box foreground color */
int BgColor = 7; /* Edit box background color */
int DesktopFg = 1; /* Desktop foreground color */
int DesktopBg = 7; /* Desktop background color */
int HighlightFg = 15; /* Submenu highlighter bar fg color */
int HighlightBg = 0; /* Submenu highlighter bar bg color */
int InfoColorFg = 0; /* Information field foreground color */
int InfoColorBg = 7; /* Information field background color */
int IMForeColor = 15; /* Info menu foreground color */
int IMBackColor = 2; /* Info menu background color */
int MMForeColor = 15; /* Main menu foreground color */
int MMBackColor = 1; /* Main menu background color */
int MMHighlightFg = 1; /* Main menu highlighter bar fg color */
int MMHighlightBg = 7; /* Main menu highlighter bar bg color */
int OMForeColor = 15; /* Other menu foreground color */
int OMBackColor = 1; /* Other menu background color */
int OMHighlightFg = 1; /* Other menu highlighter bar fg color */
int OMHighlightBg = 7; /* Other menu highlighter bar bg color */
void AboutScreen(void);
void ChCurLevel(void);
void ChCurPrim(void);
void ChCurSec(void);
void ChLazerStr(void);
void ChLazerT(void);
void ChMaxLevel(void);
void ChNumConcl(void);
void ChNumHom(void);
void ChNumLives(void);
void ChNumMega(void);
void ChNumProx(void);
void ChNumSmart(void);
void ChSaveGame(void);
void ChSaveName(void);
void ChSheildStr(void);
void ChSkillLevel(void);
void Toggles(void);
void cursor(short OnOff);
void drawbox(int x1, int y1, int x2, int y2, int fc, int bc, char *msg);
void getinp(unsigned int *Num, unsigned int deflt);
void getvidseg(void);
void mainmenu(void);
void othermenu(void);
void setvars(void);
void main(int argc, char *argv[]) {
if (argc != 2) {
printf("Syntax: DSGE <player.plr>\n\r");
exit(1);
}
FileName = argv[1];
if ((File = fopen(FileName, "r+b")) == NULL) {
printf("Error opening %s\n\r", FileName);
exit(1);
}
fread(FileBuff, sizeof(FileBuff), 1, File);
for (I = 0; I <= HeaderLen; I++)
if (FileBuff[I] != PlayerHeader[I]) {
printf("Invalid player file\n\r");
exit(1);
}
getvidseg();
directvideo = 1;
movedata(VideoSeg, 0x0, _DS, (unsigned) ScrnBuff, sizeof(ScrnBuff));
gettextinfo(&ti);
if (VideoSeg == 0xB800)
textmode(C80);
else
textmode(MONO);
cursor(0);
BaseInfo = 0x14;
textcolor(DesktopFg);
textbackground(DesktopBg);
clrscr();
setvars();
gotoxy(1, 2);
for (I = 1; I <= 1840; I++)
cprintf("%c", 176);
textcolor(InfoColorFg);
textbackground(InfoColorBg);
gotoxy(4, 1);
cprintf("DSGE v1.00");
gotoxy(57, 1);
cprintf("Written by Andrew Pye");
drawbox(omx1, omy1, omx2, omy2, OMForeColor, OMBackColor, "\x0");
for (I = 0; I <= (MaxOMenuItems - 1); I++) {
gotoxy(omx1 + 1, omy1 + (I + 2));
cprintf(" %s", OMenuItem[I]);
}
mainmenu();
movedata(_DS, (unsigned) ScrnBuff, VideoSeg, 0x0, sizeof(ScrnBuff));
textmode(ti.currmode);
gotoxy(ti.curx, ti.cury);
cursor(1);
}
void AboutScreen(void) {
drawbox(20, 10, 60, 15, FgColor, BgColor, "About ");
gotoxy(37, 10);
cprintf(" About ");
gotoxy(35, 12);
cprintf("DSGE v1.00");
gotoxy(30, 13);
cprintf("Written by Andrew Pye");
getch();
}
void ChCurLevel(void) {
char tmp, tmp1;
drawbox(33, 11, 48, 14, FgColor, BgColor, "Change Current Level (1 - 7)");
gotoxy(35, 12);
cprintf("Current: %i", FileBuff[BaseInfo + 0xA6]);
tmp1 = FileBuff[BaseInfo + 0xA6];
gotoxy(35, 13);
cprintf("New : ");
do {
do
tmp = getch();
while ((tmp != 13 && tmp != 27) && (tmp > 0x37 || tmp < 0x30));
if (tmp != 13 && tmp != 27) {
gotoxy(44, 13);
cprintf("%c", tmp);
tmp -= 0x30;
FileBuff[BaseInfo + 0xA6] = tmp;
}
} while (tmp != 13 && tmp != 27);
if (tmp == 27)
FileBuff[BaseInfo + 0xA6] = tmp1;
}
void ChCurPrim(void) {
char Inp;
int CItem = FileBuff[BaseInfo + 0x92];
drawbox(24, 8, 55, 16, FgColor, BgColor, "Change Current Primary Weapon");
strcpy(MiscMenuItem[0], "Lazer Cannon");
strcpy(MiscMenuItem[1], "Vulcan Cannon");
strcpy(MiscMenuItem[2], "Spreadfire Cannon");
strcpy(MiscMenuItem[3], "Plasma Cannon");
strcpy(MiscMenuItem[4], "Fusion Cannon");
do {
for (I = 0; I <= 4; I++) {
gotoxy(25, (I + 10));
if (CItem == I) {
textcolor(HighlightFg);
textbackground(HighlightBg);
} else {
textcolor(FgColor);
textbackground(BgColor);
}
cprintf(" %s", MiscMenuItem[I]);
while (wherex() != 55)
cprintf(" ");
}
movedata(VideoSeg, 0x0, _DS, (unsigned) MiscMenuBuff, sizeof(MiscMenuBuff));
Inp = getch();
switch(Inp) {
case 0:
Inp = getch();
switch(Inp) {
case 80: /* Down */
if (CItem != 4)
CItem++;
else
CItem = 0;
break;
case 72: /* Up */
if (CItem != 0)
CItem--;
else
CItem = 4;
break;
default:
break;
}
break;
case 13:
FileBuff[BaseInfo + 0x92] = CItem;
break;
default:
break;
}
movedata(_DS, (unsigned) MiscMenuBuff, VideoSeg, 0x0, sizeof(MiscMenuBuff));
} while (Inp != 27 && Inp != 13);
}
void ChCurSec(void) {
char Inp;
int CItem = FileBuff[BaseInfo + 0x96];
drawbox(24, 8, 55, 16, FgColor, BgColor, "Change Current Secondary Weapon");
strcpy(MiscMenuItem[0], "Conclusion Missile");
strcpy(MiscMenuItem[1], "Homing Missile");
strcpy(MiscMenuItem[2], "Proximity Bomb");
strcpy(MiscMenuItem[3], "Smart Missile");
strcpy(MiscMenuItem[4], "Mega Missile");
do {
for (I = 0; I <= 4; I++) {
gotoxy(25, (I + 10));
if (CItem == I) {
textcolor(HighlightFg);
textbackground(HighlightBg);
} else {
textcolor(FgColor);
textbackground(BgColor);
}
cprintf(" %s", MiscMenuItem[I]);
while (wherex() != 55)
cprintf(" ");
}
movedata(VideoSeg, 0x0, _DS, (unsigned) MiscMenuBuff, sizeof(MiscMenuBuff));
Inp = getch();
switch(Inp) {
case 0:
Inp = getch();
switch(Inp) {
case 80: /* Down */
if (CItem != 4)
CItem++;
else
CItem = 0;
break;
case 72: /* Up */
if (CItem != 0)
CItem--;
else
CItem = 4;
break;
default:
break;
}
break;
case 13:
FileBuff[BaseInfo + 0x96] = CItem;
break;
default:
break;
}
movedata(_DS, (unsigned) MiscMenuBuff, VideoSeg, 0x0, sizeof(MiscMenuBuff));
} while (Inp != 27 && Inp != 13);
}
void ChLazerT(void) {
char Inp;
int CItem = 0;
switch(FileBuff[BaseInfo + 0x44]) {
case 0:
CItem = 0;
break;
case 1:
CItem = 1;
break;
case 2:
CItem = 2;
break;
case 3:
CItem = 3;
break;
case 4:
CItem = 4;
break;
case 5:
CItem = 5;
break;
case 6:
CItem = 6;
break;
case 8:
CItem = 7;
break;
case 9:
CItem = 8;
break;
case 10:
CItem = 9;
break;
case 11:
CItem = 10;
break;
case 12:
CItem = 11;
break;
case 15:
CItem = 12;
break;
case 16:
CItem = 13;
break;
case 17:
CItem = 14;
break;
case 19:
CItem = 15;
break;
}
drawbox(24, 3, 55, 22, FgColor, BgColor, "Change Lazer Type");
strcpy(MiscMenuItem[0], "Lazer Type 1");
strcpy(MiscMenuItem[1], "Lazer Type 2");
strcpy(MiscMenuItem[2], "Lazer Type 3");
strcpy(MiscMenuItem[3], "Lazer Type 4");
strcpy(MiscMenuItem[4], "Blue Balls");
strcpy(MiscMenuItem[5], "Orange Balls");
strcpy(MiscMenuItem[6], "Red Balls");
strcpy(MiscMenuItem[7], "Conclusion Missiles");
strcpy(MiscMenuItem[8], "Flares");
strcpy(MiscMenuItem[9], "Blue Lazers");
strcpy(MiscMenuItem[10], "Vulcan Ammo");
strcpy(MiscMenuItem[11], "Spreadfire Ammo");
strcpy(MiscMenuItem[12], "Homing Missile");
strcpy(MiscMenuItem[13], "Proximity Bombs");
strcpy(MiscMenuItem[14], "Smart Missiles");
strcpy(MiscMenuItem[15], "Plasma Cannon");
do {
for (I = 0; I <= 15; I++) {
gotoxy(25, (I + 5));
if (CItem == I) {
textcolor(HighlightFg);
textbackground(HighlightBg);
} else {
textcolor(FgColor);
textbackground(BgColor);
}
cprintf(" %s", MiscMenuItem[I]);
while (wherex() != 55)
cprintf(" ");
}
movedata(VideoSeg, 0x0, _DS, (unsigned) MiscMenuBuff, sizeof(MiscMenuBuff));
Inp = getch();
switch(Inp) {
case 0:
Inp = getch();
switch(Inp) {
case 80: /* Down */
if (CItem != 15)
CItem++;
else
CItem = 0;
break;
case 72: /* Up */
if (CItem != 0)
CItem--;
else
CItem = 15;
break;
default:
break;
}
break;
case 13:
switch(CItem) {
case 0:
CItem = 0;
break;
case 1:
CItem = 1;
break;
case 2:
CItem = 2;
break;
case 3:
CItem = 3;
break;
case 4:
CItem = 4;
break;
case 5:
CItem = 5;
break;
case 6:
CItem = 6;
break;
case 7:
CItem = 8;
break;
case 8:
CItem = 9;
break;
case 9:
CItem = 10;
break;
case 10:
CItem = 11;
break;
case 11:
CItem = 12;
break;
case 12:
CItem = 15;
break;
case 13:
CItem = 16;
break;
case 14:
CItem = 17;
break;
case 15:
CItem = 19;
break;
}
FileBuff[BaseInfo + 0x44] = CItem;
break;
default:
break;
}
movedata(_DS, (unsigned) MiscMenuBuff, VideoSeg, 0x0, sizeof(MiscMenuBuff));
} while (Inp != 27 && Inp != 13);
}
void ChLazerStr(void) {
int tmp, tmp1;
drawbox(32, 11, 49, 14, FgColor, BgColor, "Change Lazer Energy (0 - 32767)");
gotoxy(34, 12);
_DL = FileBuff[BaseInfo + 0x3C];
_DH = FileBuff[BaseInfo + 0x3D];
tmp1 = _DX + 1;
cprintf("Current: %i", tmp1);
gotoxy(34, 13);
cprintf("New : ");
getinp(&tmp, tmp1);
_DX = tmp - 1;
// FileBuff[BaseInfo + 0x3C] = tmp - 1;
FileBuff[BaseInfo + 0x3C] = _DL;
FileBuff[BaseInfo + 0x3D] = _DH;
}
void ChMaxLevel(void) {
char tmp, tmp1;
drawbox(33, 11, 47, 14, FgColor, BgColor, "Change Maximum Accessible Level (1 - 7)");
gotoxy(35, 12);
cprintf("Current: %i", FileBuff[8]);
tmp1 = FileBuff[8];
gotoxy(35, 13);
cprintf("New : ");
do {
do
tmp = getch();
while ((tmp != 13 && tmp != 27) && (tmp > 0x37 || tmp < 0x30));
if (tmp != 13 && tmp != 27) {
gotoxy(44, 13);
cprintf("%c", tmp);
tmp -= 0x30;
FileBuff[8] = tmp;
}
} while (tmp != 13 && tmp != 27);
if (tmp == 27)
FileBuff[8] = tmp1;
}
void ChNumConcl(void) {
unsigned int tmp, tmp1;
drawbox(32, 11, 49, 14, FgColor, BgColor, "Change Number of Conclusion Missiles (0 - 65535)");
gotoxy(34, 12);
_DL = FileBuff[BaseInfo + 0x54];
_DH = FileBuff[BaseInfo + 0x55];
tmp1 = _DX;
cprintf("Current: %u", tmp1);
gotoxy(34, 13);
cprintf("New : ");
getinp(&tmp, tmp1);
_DX = tmp;
FileBuff[BaseInfo + 0x54] = _DL;
FileBuff[BaseInfo + 0x55] = _DH;
}
void ChNumHom(void) {
unsigned int tmp, tmp1;
drawbox(32, 11, 49, 14, FgColor, BgColor, "Change Number of Homing Missiles (0 - 65535)");
gotoxy(34, 12);
_DL = FileBuff[BaseInfo + 0x56];
_DH = FileBuff[BaseInfo + 0x57];
tmp1 = _DX;
cprintf("Current: %u", tmp1);
gotoxy(34, 13);
cprintf("New : ");
getinp(&tmp, tmp1);
_DX = tmp;
FileBuff[BaseInfo + 0x56] = _DL;
FileBuff[BaseInfo + 0x57] = _DH;
}
void ChNumMega(void) {
unsigned int tmp, tmp1;
drawbox(32, 11, 49, 14, FgColor, BgColor, "Change Number of Mega Missiles (0 - 65535)");
gotoxy(34, 12);
_DL = FileBuff[BaseInfo + 0x5C];
_DH = FileBuff[BaseInfo + 0x5D];
tmp1 = _DX;
cprintf("Current: %u", tmp1);
gotoxy(34, 13);
cprintf("New : ");
getinp(&tmp, tmp1);
_DX = tmp;
FileBuff[BaseInfo + 0x5C] = _DL;
FileBuff[BaseInfo + 0x5D] = _DH;
}
void ChNumLives(void) {
unsigned int tmp, tmp1;
drawbox(32, 11, 49, 14, FgColor, BgColor, "Change Number of Lives (0 - ???? (65536 max))");
gotoxy(34, 12);
_DL = FileBuff[BaseInfo + 0x42];
_DH = FileBuff[BaseInfo + 0x43];
tmp1 = _DX + 1;
cprintf("Current: %u", tmp1);
gotoxy(34, 13);
cprintf("New : ");
getinp(&tmp, tmp1);
_DX = tmp - 1;
FileBuff[BaseInfo + 0x42] = _DL;
FileBuff[BaseInfo + 0x43] = _DH;
}
void ChNumProx(void) {
unsigned int tmp, tmp1;
drawbox(32, 11, 49, 14, FgColor, BgColor, "Change Numbe of Proximity Bombs (0 - 65535)");
gotoxy(34, 12);
_DL = FileBuff[BaseInfo + 0x58];
_DH = FileBuff[BaseInfo + 0x59];
tmp1 = _DX;
cprintf("Current: %u", tmp1);
gotoxy(34, 13);
cprintf("New : ");
getinp(&tmp, tmp1);
_DX = tmp;
FileBuff[BaseInfo + 0x58] = _DL;
FileBuff[BaseInfo + 0x59] = _DH;
}
void ChNumSmart(void) {
unsigned int tmp, tmp1;
drawbox(32, 11, 49, 14, FgColor, BgColor, "Change Number of Smart Missiles (0 - 65535)");
gotoxy(34, 12);
_DL = FileBuff[BaseInfo + 0x5A];
_DH = FileBuff[BaseInfo + 0x5B];
tmp1 = _DX;
cprintf("Current: %u", tmp1);
gotoxy(34, 13);
cprintf("New : ");
getinp(&tmp, tmp1);
_DX = tmp;
FileBuff[BaseInfo + 0x5A] = _DL;
FileBuff[BaseInfo + 0x5B] = _DH;
}
void ChSaveGame(void) {
char Inp;
int CItem = ((BaseInfo - 0x14) / 0xAE), I1, I2;
drawbox(24, 6, 55, 19, FgColor, BgColor, "Change Current Save Game");
I = 0x14;
for (I1 = 0; I1 <= 9; I1++) {
I2 = 0;
do {
MiscMenuItem[I1][I2] = FileBuff[I + I2];
I2++;
} while (FileBuff[I + I2] != '\x0');
MiscMenuItem[I1][I2] = '\x0';
I += 0xAE;
}
do {
for (I = 0; I <= 9; I++) {
gotoxy(25, (I + 8));
if (CItem == I) {
textcolor(HighlightFg);
textbackground(HighlightBg);
} else {
textcolor(FgColor);
textbackground(BgColor);
}
cprintf(" %s", MiscMenuItem[I]);
while (wherex() != 55)
cprintf(" ");
}
movedata(VideoSeg, 0x0, _DS, (unsigned) MiscMenuBuff, sizeof(MiscMenuBuff));
Inp = getch();
switch(Inp) {
case 0:
Inp = getch();
switch(Inp) {
case 80: /* Down */
if (CItem != 9)
CItem++;
else
CItem = 0;
break;
case 72: /* Up */
if (CItem != 0)
CItem--;
else
CItem = 9;
break;
default:
break;
}
break;
case 13:
BaseInfo = (CItem * 0xAE) + 0x14;
for (I = 0; I <= sizeof(SaveGame); I++)
SaveGame[I] = MiscMenuItem[CItem][I];
break;
default:
break;
}
movedata(_DS, (unsigned) MiscMenuBuff, VideoSeg, 0x0, sizeof(MiscMenuBuff));
} while (Inp != 27 && Inp != 13);
}
void ChSaveName(void) {
char tmp, TempStr[25];
int I1;
drawbox(21, 11, 59, 14, FgColor, BgColor, "Change Name of Save Game");
gotoxy(23, 12);
I = 0;
cprintf("Current : %s", SaveGame);
gotoxy(23, 13);
cprintf("New : ");
I = 0;
for (I1 = 0; I1 <= sizeof(SaveGame); I1++)
TempStr[I1] = '\x0';
do {
tmp = getch();
switch(tmp) {
case 8:
if (I > 0) {
I--;
TempStr[I] = '\x0';
cprintf("\b \b");
}
break;
default:
if (I <= (sizeof(SaveGame) - 1) && tmp != 13 && tmp != 27 && tmp != 0) {
TempStr[I] = tmp;
I++;
cprintf("%c", tmp);
}
break;
}
} while (tmp != 13 && tmp != 27);
if (tmp == 13 && TempStr[0] != 0)
for (I1 = 0; I1 < sizeof(SaveGame); I1++) {
FileBuff[BaseInfo + I1] = TempStr[I1];
SaveGame[I1] = TempStr[I1];
}
}
void ChSheildStr(void) {
int tmp, tmp1;
drawbox(32, 11, 49, 14, FgColor, BgColor, "Change Sheild Energy (0 - 32767)");
gotoxy(34, 12);
_DL = FileBuff[BaseInfo + 0x40];
_DH = FileBuff[BaseInfo + 0x41];
tmp1 = _DX;
cprintf("Current: %i", tmp1);
gotoxy(34, 13);
cprintf("New : ");
getinp(&tmp, tmp1);
_DX = tmp;
FileBuff[BaseInfo + 0x40] = _DL;
FileBuff[BaseInfo + 0x41] = _DH;
}
void ChSkillLevel(void) {
char Inp;
int CItem = FileBuff[BaseInfo + 0x8E];
drawbox(24, 8, 55, 16, FgColor, BgColor, "Change Skill Level");
strcpy(MiscMenuItem[0], "Trainee");
strcpy(MiscMenuItem[1], "Rookie");
strcpy(MiscMenuItem[2], "Hotshot");
strcpy(MiscMenuItem[3], "Ace");
strcpy(MiscMenuItem[4], "Insane");
do {
for (I = 0; I <= 4; I++) {
gotoxy(25, (I + 10));
if (CItem == I) {
textcolor(HighlightFg);
textbackground(HighlightBg);
} else {
textcolor(FgColor);
textbackground(BgColor);
}
cprintf(" %s", MiscMenuItem[I]);
while (wherex() != 55)
cprintf(" ");
}
movedata(VideoSeg, 0x0, _DS, (unsigned) MiscMenuBuff, sizeof(MiscMenuBuff));
Inp = getch();
switch(Inp) {
case 0:
Inp = getch();
switch(Inp) {
case 80: /* Down */
if (CItem != 4)
CItem++;
else
CItem = 0;
break;
case 72: /* Up */
if (CItem != 0)
CItem--;
else
CItem = 4;
break;
default:
break;
}
break;
case 13:
FileBuff[BaseInfo + 0x8E] = CItem;
break;
default:
break;
}
movedata(_DS, (unsigned) MiscMenuBuff, VideoSeg, 0x0, sizeof(MiscMenuBuff));
} while (Inp != 27 && Inp != 13);
}
void Toggles(void) {
char Inp, TmpToggle[3];
int CItem = 0;
drawbox(25, 6, 54, 20, FgColor, BgColor, "Toggles ");
TmpToggle[0] = FileBuff[BaseInfo + 0x37];
TmpToggle[1] = FileBuff[BaseInfo + 0x48];
TmpToggle[2] = FileBuff[BaseInfo + 0x49];
do {
if (TmpToggle[0] & 4)
strcpy(MiscMenuItem[0], "[X] Quad Lazers");
else
strcpy(MiscMenuItem[0], "[ ] Quad Lazers");
if (TmpToggle[1] & 1)
strcpy(MiscMenuItem[1], "[X] Lazer Cannon");
else
strcpy(MiscMenuItem[1], "[ ] Lazer Cannon");
if (TmpToggle[1] & 2)
strcpy(MiscMenuItem[2], "[X] Vulcan Cannon");
else
strcpy(MiscMenuItem[2], "[ ] Vulcan Cannon");
if (TmpToggle[1] & 4)
strcpy(MiscMenuItem[3], "[X] Spreadfire Cannon");
else
strcpy(MiscMenuItem[3], "[ ] Spreadfire Cannon");
if (TmpToggle[1] & 8)
strcpy(MiscMenuItem[4], "[X] Plasma Cannon");
else
strcpy(MiscMenuItem[4], "[ ] Plasma Cannon");
if (TmpToggle[1] & 16)
strcpy(MiscMenuItem[5], "[X] Fusion Cannon");
else
strcpy(MiscMenuItem[5], "[ ] Fusion Cannon");
if (TmpToggle[2] & 1)
strcpy(MiscMenuItem[6], "[X] Conclusion Missiles");
else
strcpy(MiscMenuItem[6], "[ ] Conclusion Missiles");
if (TmpToggle[2] & 2)
strcpy(MiscMenuItem[7], "[X] Homing Missiles");
else
strcpy(MiscMenuItem[7], "[ ] Homing Missiles");
if (TmpToggle[2] & 4)
strcpy(MiscMenuItem[8], "[X] Proximity Bombs");
else
strcpy(MiscMenuItem[8], "[ ] Proximity Bombs");
if (TmpToggle[2] & 8)
strcpy(MiscMenuItem[9], "[X] Smart Missiles");
else
strcpy(MiscMenuItem[9], "[ ] Smart Missiles");
if (TmpToggle[2] & 16)
strcpy(MiscMenuItem[10], "[X] Mega Missiles");
else
strcpy(MiscMenuItem[10], "[ ] Mega Missiles");
for (I = 0; I <= 10; I++) {
gotoxy(26, (I + 8));
if (CItem == I) {
textcolor(HighlightFg);
textbackground(HighlightBg);
} else {
textcolor(FgColor);
textbackground(BgColor);
}
cprintf(" %s", MiscMenuItem[I]);
while (wherex() != 54)
cprintf(" ");
}
movedata(VideoSeg, 0x0, _DS, (unsigned) MiscMenuBuff, sizeof(MiscMenuBuff));
Inp = getch();
switch(Inp) {
case 0:
Inp = getch();
switch(Inp) {
case 80: /* Down */
if (CItem != 10)
CItem++;
else
CItem = 0;
break;
case 72: /* Up */
if (CItem != 0)
CItem--;
else
CItem = 10;
break;
default:
break;
}
break;
case 32:
switch(CItem) {
case 0:
if (TmpToggle[0] & 4)
TmpToggle[0] &= 251;
else
TmpToggle[0] |= 4;
break;
case 1:
if (TmpToggle[1] & 1)
TmpToggle[1] &= 254;
else
TmpToggle[1] |= 1;
break;
case 2:
if (TmpToggle[1] & 2)
TmpToggle[1] &= 253;
else
TmpToggle[1] |= 2;
break;
case 3:
if (TmpToggle[1] & 4)
TmpToggle[1] &= 251;
else
TmpToggle[1] |= 4;
break;
case 4:
if (TmpToggle[1] & 8)
TmpToggle[1] &= 247;
else
TmpToggle[1] |= 8;
break;
case 5:
if (TmpToggle[1] & 16)
TmpToggle[1] &= 239;
else
TmpToggle[1] |= 16;
break;
case 6:
if (TmpToggle[2] & 1)
TmpToggle[2] &= 254;
else
TmpToggle[2] |= 1;
break;
case 7:
if (TmpToggle[2] & 2)
TmpToggle[2] &= 253;
else
TmpToggle[2] |= 2;
break;
case 8:
if (TmpToggle[2] & 4)
TmpToggle[2] &= 251;
else
TmpToggle[2] |= 4;
break;
case 9:
if (TmpToggle[2] & 8)
TmpToggle[2] &= 247;
else
TmpToggle[2] |= 8;
break;
case 10:
if (TmpToggle[2] & 16)
TmpToggle[2] &= 239;
else
TmpToggle[2] |= 16;
break;
}
break;
case 13:
FileBuff[BaseInfo + 0x37] = TmpToggle[0];
FileBuff[BaseInfo + 0x48] = TmpToggle[1];
FileBuff[BaseInfo + 0x49] = TmpToggle[2];
break;
default:
break;
}
movedata(_DS, (unsigned) MiscMenuBuff, VideoSeg, 0x0, sizeof(MiscMenuBuff));
} while (Inp != 27 && Inp != 13);
}
void cursor(short OnOff) {
asm {
Cmp OnOff, 001h
Jnz _CursorOff
Mov AX, 00100h
Mov CX, 00506h
Int 010h
Jmp _End
}
_CursorOff: ;
asm {
Mov AX, 00100h
Mov CX, 02607h
Int 010h
}
_End: ;
}
void drawbox(int x1, int y1, int x2, int y2, int fc, int bc, char *msg) {
int I1;
if (msg[0] != 0) {
gotoxy(2, 25);
textcolor(InfoColorFg);
textbackground(InfoColorBg);
cprintf("%s", msg);
}
textcolor(fc);
textbackground(bc);
gotoxy(x1, y1);
cprintf("%c", 201);
for (I = (x1 + 1); I < x2; I++)
cprintf("%c", 205);
cprintf("%c", 187);
gotoxy(x1, (y1 + 1));
for (I = (y1 + 1); I < y2; I++) {
cprintf("%c", 186);
for (I1 = (x1 + 1); I1 < x2; I1++)
cprintf(" ");
cprintf("%c", 186);
gotoxy(x1, (I + 1));
}
gotoxy(x1, y2);
cprintf("%c", 200);
for (I = (x1 + 1); I < x2; I++)
cprintf("%c", 205);
cprintf("%c", 188);
}
void getinp(unsigned int *Num, unsigned int dflt) {
char temp, TempStr[5];
int Len = 0;
for (I = 0; I < sizeof(TempStr); I++)
TempStr[I] = '\x0';
do {
temp = getch();
switch(temp) {
case 8:
if (Len != 0) {
TempStr[Len] = '\x0';
Len--;
cprintf("\b \b");
}
break;
case 13:
if (TempStr[0] == '\x0')
*Num = dflt;
else {
*Num = atoi(TempStr);
}
break;
case 27:
*Num = dflt;
break;
default:
if (Len < sizeof(TempStr) && temp > 0x2A && temp < 0x3A) {
TempStr[Len] = temp;
Len++;
cprintf("%c", temp);
}
break;
}
} while (temp != 27 && temp != 13);
}
void getvidseg(void) {
asm {
Push ES
Mov AX, 00040h
Mov ES, AX
Mov AX, ES:[00063h]
Cmp AX, 003D4h
Je _Color
}
VideoSeg = 0xB800;
goto _End;
_Color: ;
VideoSeg = 0xB800;
_End: ;
asm Pop ES
}
void mainmenu(void) {
drawbox(mmx1, mmy1, mmx2, mmy2, MMForeColor, MMBackColor, "Select Item");
drawbox(imx1, imy1, imx2, imy2, IMForeColor, IMBackColor, "\x0");
do {
for (I = 0; I <= (MaxMenuItems - 1); I++) { /* Main Menu items */
gotoxy(mmx1 + 1, mmy1 + (I + 2));
if (MMItem == I) {
textcolor(MMHighlightFg);
textbackground(MMHighlightBg);
} else {
textcolor(MMForeColor);
textbackground(MMBackColor);
}
cprintf(" %s", MMenuItem[I]);
while (wherex() != mmx2)
cprintf(" ");
}
textcolor(IMForeColor);
textbackground(IMBackColor);
gotoxy(imx1 + 2, imy1 + 2);
cprintf("Player Name:");
gotoxy(imx1 + 4, imy1 + 3);
cprintf("%s", PlayerName);
gotoxy(imx1 + 2, imy1 + 4);
cprintf("Current Save Game:");
gotoxy(imx1 + 4, imy1 + 5);
cprintf("%s", SaveGame);
while (wherex() != (imx2))
cprintf(" ");
/* textcolor(LIGHTRED + BLINK);
gotoxy(((imx2 - imx1) / 2) + imx1 - 6, imy1);
cprintf(" REGISTERED "); */
movedata(VideoSeg, 0x0, _DS, (unsigned) MainMenuBuff, sizeof(MainMenuBuff));
while (! kbhit())
if (error == 1) {
gotoxy(2, 25);
textcolor(InfoColorFg);
textbackground(InfoColorBg);
cprintf("Error writing to file");
textcolor(MMForeColor);
textbackground(MMBackColor);
} else
if (error == 2) {
gotoxy(2, 25);
textcolor(InfoColorFg);
textbackground(InfoColorBg);
cprintf("File saved ");
textcolor(MMForeColor);
textbackground(MMBackColor);
}
error = 0;
input = getch();
switch(input) {
case 0:
input = getch();
switch (input) {
case 30:
AboutScreen();
break;
case 80: /* Down */
if (MMItem != (MaxMenuItems - 1))
MMItem++;
else
MMItem = 0;
break;
case 72: /* Up */
if (MMItem != 0)
MMItem--;
else
MMItem = (MaxMenuItems - 1);
break;
case 77: /* Right */
othermenu();
break;
default:
break;
}
break;
case 9: /* Tab */
othermenu();
break;
case 13:
switch(MMItem) {
case 0:
ChSaveGame();
break;
case 1:
ChSaveName();
break;
case 2:
ChMaxLevel();
break;
case 3:
ChCurLevel();
break;
case 4:
ChNumLives();
break;
case 5:
ChNumConcl();
break;
case 6:
ChNumHom();
break;
case 7:
ChNumProx();
break;
case 8:
ChNumSmart();
break;
case 9:
ChNumMega();
break;
case 10:
ChCurPrim();
break;
case 11:
ChCurSec();
break;
case 12:
ChLazerT();
break;
case 13:
ChSheildStr();
break;
case 14:
ChLazerStr();
break;
case 15:
ChSkillLevel();
break;
case 16:
Toggles();
break;
case (MaxMenuItems - 2):
rewind(File);
if (fwrite(&FileBuff, sizeof(FileBuff), 1, File) != sizeof(FileBuff)) {
error = 2;
rewind(File);
for (I = 0; I <= sizeof(FileBuff); I++)
FileBuff[I] = '\x0';
fread(FileBuff, sizeof(FileBuff), 1, File);
}
else
error = 1;
break;
case (MaxMenuItems - 1):
input = 27;
break;
default:
break;
}
break;
default:
break;
}
movedata(_DS, (unsigned) MainMenuBuff, VideoSeg, 0x0, sizeof(MainMenuBuff));
} while (input != 27);
fclose(File);
}
void othermenu(void) { // Only call from main menu!
int Input;
textcolor(MMForeColor);
textbackground(MMBackColor);
gotoxy(mmx1 + 1, mmy1 + (MMItem + 2));
cprintf(" %s", MMenuItem[MMItem]);
while (wherex() != mmx2)
cprintf(" ");
do {
for (I = 0; I <= (MaxOMenuItems - 1); I++) {
gotoxy(omx1 + 1, omy1 + (I + 2));
if (OMItem == I) {
textcolor(OMHighlightFg);
textbackground(OMHighlightBg);
} else {
textcolor(OMForeColor);
textbackground(OMBackColor);
}
cprintf(" %s", OMenuItem[I]);
while (wherex() != omx2)
cprintf(" ");
}
movedata(VideoSeg, 0x0, _DS, (unsigned) MainMenuBuff, sizeof(MainMenuBuff));
Input = getch();
switch(Input) {
case 0:
Input = getch();
switch (Input) {
case 30:
AboutScreen();
break;
case 80: /* Down */
if (OMItem != (MaxOMenuItems - 1))
OMItem++;
else
OMItem = 0;
break;
case 72: /* Up */
if (OMItem != 0)
OMItem--;
else
OMItem = (MaxOMenuItems - 1);
break;
case 75: /* Left */
Input = 9;
break;
default:
break;
}
break;
case 13:
switch(OMItem) {
case 0:
AboutScreen();
break;
}
break;
case 27:
Input = 9;
input = 27;
break;
default:
break;
}
movedata(_DS, (unsigned) MainMenuBuff, VideoSeg, 0x0, sizeof(MainMenuBuff));
} while (Input != 9);
textcolor(OMForeColor);
textbackground(OMBackColor);
gotoxy(omx1 + 1, omy1 + (2 + OMItem));
cprintf(" %s", OMenuItem[OMItem]);
while (wherex() != omx2)
cprintf(" ");
movedata(VideoSeg, 0x0, _DS, (unsigned) MainMenuBuff, sizeof(MainMenuBuff));
}
void setvars(void) {
int I1;
for (I1 = 0; I1 <= 7; I1++)
PlayerName[I1] = FileBuff[I1 + 0x2E];
for (I1 = 0; I1 <= 24; I1++)
SaveGame[I1] = FileBuff[I1 + BaseInfo];
MMenuItem[0] = "Change Save Game";
MMenuItem[1] = "Change Save Game Name";
MMenuItem[2] = "Change Maximum Level";
MMenuItem[3] = "Change Current Level";
MMenuItem[4] = "Change # of Lives";
MMenuItem[5] = "Change # of Conclusion Missiles";
MMenuItem[6] = "Change # of Homing Missiles";
MMenuItem[7] = "Change # of Proximity Bombs";
MMenuItem[8] = "Change # of Smart Missiles";
MMenuItem[9] = "Change # of Mega Missiles";
MMenuItem[10] = "Change Current Primary Weapon";
MMenuItem[11] = "Change Current Secondary Weapon";
MMenuItem[12] = "Change Lazer Type";
MMenuItem[13] = "Change Sheild Energy";
MMenuItem[14] = "Change Lazer Energy";
MMenuItem[15] = "Change Skill Level";
MMenuItem[16] = "Toggles";
MMenuItem[17] = "Save Player";
MMenuItem[18] = "Exit";
OMenuItem[0] = "About";
}